var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    arrayss: ['是', '否'],
    indexs:0
  },


  onLoad: function (options) {
    var djq_id = options.id;
    this.setData({
      djq_id:djq_id
    })
    this.getDaiJinQuanInfo();
  },

  setTitle:function(e){
    this.setData({
      title:e.detail.value
    })
  },

  setPrice:function(e){
    this.setData({
      price:e.detail.value
    })
  },

  setDkprice:function(e){
    this.setData({
      dk_price:e.detail.value
    })
  },

  getDaiJinQuanInfo:function(){
    var t = this;
    app.visit("huodong/getDaiJinQuanInfo", {
      djq_id:t.data.djq_id,
    }, "", function(c) {
      console.log(c)
      if(0 == c.code){
        t.setData({
          info:c.data,
          title:c.data.title,
          price:c.data.price,
          dk_price:c.data.dk_price,
          indexs:c.data.is_chara==2?0:1
        })
      }else{
        app.showToast(c.msg)
      }
    })
  },

  bindPickerChangess: function (e) {
    this.setData({
      indexs: e.detail.value
    })
  },

  tijiao:function(e){
    var t = this;
    if (!(/(^[0-9]+(.[0-9]{1,2})?$)/.test(t.data.price))) {
      app.myToast("所猜价格只能输入数字！")
    }else if (!(/(^[0-9]+(.[0-9]{1,2})?$)/.test(t.data.dk_price))) {
      app.myToast("所猜价格只能输入数字！")
    }else{
      app.visit("huodong/setDaiJinQuanInfo", {
        djq_id:t.data.djq_id,
        title:t.data.title,
        price:t.data.price,
        dk_price:t.data.dk_price,
        index:t.data.indexs,
      }, "", function(c) {
        console.log(c)
        if(0 == c.code){
          wx.showToast({
            title: '修改成功',
            icon: 'none',
            success: function () {
              wx.navigateBack();
            }
          })
        }else{
          app.showToast(c.msg)
        }
      })
    }
  },

})